package cn.ncu.wechat.controller;

import cn.ncu.wechat.model.dto.ProductBatchRequest;
import cn.ncu.wechat.service.ProductCategoryService;
import cn.ncu.wechat.service.ProductService;
import cn.ncu.wechat.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class adminProductController {
    @Autowired
    private ProductCategoryService productCategoryService;

    @Autowired
    private ProductService productService;

    @GetMapping("/api/admin/product-categories/options")
    public Result<?> getProductCategories() {
        return productCategoryService.getProductCategories();
    }

    @PostMapping("/api/admin/products/upload-image")
    public Result<?> uploadProductImage(@RequestParam("file") MultipartFile file) {
        return productService.uploadProductImage(file);
    }

    @GetMapping("/api/admin/products/purchase-types")
    public Result<?> getPruchaseTypes() {
        return productService.getPurchaseTypes();
    }

    @PostMapping("/api/admin/products/batch")
    public Result<?> productBatch(@RequestBody ProductBatchRequest request) {
        // 将参数传递给 Service 层
        return productService.productBatch(request);
    }

}
